﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;

public partial class _Default : System.Web.UI.Page 
{
    protected void Page_Load(object sender, EventArgs e)
    {
        this.LoadContactInfo();
    }
    protected void LoadContactInfo()
    {
        System.Text.StringBuilder builder = new System.Text.StringBuilder();

        TimeTrackerDataContext context = new TimeTrackerDataContext();

        try
        {
            var host = (from h in context.HostInformations
                        select h).Single();

            if(!string.IsNullOrEmpty(host.Name))
                builder.Append("<b>" + host.Name +"</b><br />");

            if(!string.IsNullOrEmpty(host.Address))
                builder.Append(host.Address +"<br />");

            if(!string.IsNullOrEmpty(host.City))
            { 
                builder.Append(host.City);
                if(!string.IsNullOrEmpty(host.State))
                    builder.Append(", "+host.State +" ");
                if(!string.IsNullOrEmpty(host.Zip))
                    builder.Append(" " +host.Zip);
                builder.Append("<br/>");
            }

            if(!string.IsNullOrEmpty(host.contactEmail))
                builder.AppendFormat(@"Email: <a href='mailto:{0}'>{0}</a><br />", host.contactEmail);

            if(!string.IsNullOrEmpty(host.phone))
                builder.AppendFormat("<br/>Phone: {0}<br />", host.phone);

            if(!string.IsNullOrEmpty(host.fax))
                builder.AppendFormat("Fax: {0}", host.fax);

            this.LiteralContactInfo.Text = builder.ToString();
        }
        catch
        {
        }
    }
}
